package org.wuqi.microdataservice.service;

import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wuqi.api.model.BaseInfo;
import org.wuqi.api.model.BaseInfoIndex;
import org.wuqi.api.service.PlatIndexInfo;
import org.wuqi.bean.LoanInfo;
import org.wuqi.microdataservice.mapper.BidInfoMapper;
import org.wuqi.microdataservice.mapper.LoanInfoMapper;
import org.wuqi.microdataservice.mapper.UserMapper;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author jjj
 * @program: earnest-money
 * @description:TODO
 * @date 2023-12-26 16:52:54
 */
@Service
@DubboService(interfaceClass = PlatIndexInfo.class,version = "1")
public class PlatIndexInfoImpl implements PlatIndexInfo {
//    引入mapper
    @Autowired
    private LoanInfoMapper loanInfoMapper;
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private BidInfoMapper bidInfoMapper;
    @Override
    public BaseInfoIndex queryIndexInfo() {
        //        统计总人数
        int userNum = userMapper.selectCountUser();
//        统计利率
        BigDecimal bigDecimal = loanInfoMapper.selectProductAvg();
//        总金额
        BigDecimal bigDecimal1 = bidInfoMapper.selectSumMoney();
//        查询新手宝
        List<LoanInfo> loanInfos = loanInfoMapper.selectInfoType(0);
//        优选产品
        List<LoanInfo> loanInfos1 = loanInfoMapper.selectInfoType(1);
//        散标产品
        List<LoanInfo> loanInfos2 = loanInfoMapper.selectInfoType(2);
        BaseInfoIndex baseInfoIndex = new BaseInfoIndex(bigDecimal, userNum, bigDecimal1, loanInfos, loanInfos1, loanInfos2);
        return baseInfoIndex;
    }
}
 
 